import java.util.*;

public class Main {

    public static int n;
    public static int k;
    public static List<Integer> list = new ArrayList<>(); //去重功能
    public static int sum;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        k = sc.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        dfs(arr, 0, 0);

        int count = 0;
        for (int num : list) {
            if (isPrime(num)) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    }

    /**
     *
     * @param arr
     * @param m 数组下标
     * @param size 亦轩的元素个数
     */
    public static void dfs(int[] arr, int m, int size) {
        if (size == k) {
            list.add(sum);
            return;
        }
        if (m == n) {
            return;
        }

        for (int i = m; i < n; i++) {
            //选
            sum += arr[i];
            dfs(arr, i + 1, size + 1);
            //还原现场
            sum -= arr[i];

            //不选
//            dfs(arr, i + 1, size);
        }
    }

    /**
     * 判断是否为素数
     * @param num
     * @return
     */
    public static boolean isPrime(int num) {
        if (num == 1) {
            return false;
        }
        if (num == 2) {
            return true;
        }
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}
